<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>修改密码--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <link href="/resource/css/index.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
</head>

<body class="index">
<div class="layui-form" lay-filter="example" style="margin:auto;margin-top:10px">
    <div class="top">
        <div class="layui-form-item">
            <label class="layui-form-label">支付方式</label>
            <div class="layui-input-block">
                <input type="checkbox" name="alipay" lay-skin="switch" lay-filter="alipay" lay-text="支付宝|支付宝">
                <input type="checkbox" name="wx" lay-skin="switch" lay-filter="wx" lay-text="微信|微信">
                <input type="checkbox" name="Internetbank" lay-filter="Internetbank" lay-skin="switch"
                       lay-text="网银支付|网银支付">
                <input type="checkbox" name="balance" lay-filter="balance" lay-skin="switch" lay-text="余额|余额">
            </div>
        </div>
        <div class="layui-form-item" style="margin-right:10%;margin-top: 20px">
            <div class="layui-input-block">
                <label>支付密码:</label>
                <input id="payPass" name="payPass" type="password" class="layui-input">
                <input hidden name="id" th:value="${id}">
                <input hidden name="price" th:value="${price}">
            </div>
        </div>
        <div class="notice_bot">
            <div class="r_right but_p">
                <button class="but_save layui-btn" lay-submit="" lay-filter="Submit" style="padding: 0">确认支付
                </button>
                <button class="but_close" onclick="Cancel()">取消</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript">

    var Cancel;
    layui.use(['table', 'layer', 'upload', 'form'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            upload = layui.upload,
            form = layui.form;
        Cancel = function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        }
        //监听指定开关
        form.on('switch(alipay)', function (data) {
            form.val('example', {
                "wx": false,
                "Internetbank": false,
                "balance": false,
            });
        });
        form.on('switch(wx)', function (data) {
            form.val('example', {
                "alipay": false,
                "Internetbank": false,
                "balance": false,
            });
        });
        form.on('switch(Internetbank)', function (data) {
            form.val('example', {
                "wx": false,
                "alipay": false,
                "balance": false,
            });
        });
        form.on('switch(balance)', function (data) {
            form.val('example', {
                "wx": false,
                "Internetbank": false,
                "alipay": false,
            });
        });
        form.on('submit(Submit)', function (data) {
            console.log(data.field)
            $.ajax({
                url: '/front/toPay.do',
                type: 'post',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (!result.status) {
                        parent.layer.msg(result.msg, {time: 2000});
                        return false;
                    } else {
                        parent.layer.msg("支付成功!", {time: 1000});
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.layui.table.reload('house-user-order', {});
                    }
                }

            });
        });
    });

</script>

</body>
</html>